import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { LayuiVueResolver } from 'unplugin-vue-components/resolvers'
import { resolve } from "path";

const excludeComponents = ['LightIcon','DarkIcon']

export default defineConfig({
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, './src')
      }
    ]
  },
  server: {
    host: "0.0.0.0",
    port:89,
    open: true,
    proxy: {
      '/dev-api': {
        // target: "http://127.0.0.1:4523/m1/1779816-0-default",
        target: "http://121.43.137.45:8082/dev-api/",
        // target: "http://122.51.26.254:8080",
        changeOrigin: true,
        ws: true,
        rewrite: (path) => path.replace(new RegExp("^" + '/dev-api'), "")
      },
      "/baidu-map-address": {
        target: "http://api.map.baidu.com",
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/baidu-map-address/, "")
      }
    }
  },
  plugins: [
    AutoImport({
      resolvers: [
        LayuiVueResolver(),
      ],
    }),
    Components({
      resolvers: [
        LayuiVueResolver({
          resolveIcons: true,
          exclude: excludeComponents
        }),
      ],
    }),
    vue(),
  ],
});